﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FindPwd.aspx.cs" Inherits="Maticsoft.Web.wap.FindPwd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <!--#include file="include/head.htm"-->
    <script type="text/javascript">
        function refresh() {
            document.getElementById("authImg").src = '../ValidateCode2.aspx?now=' + new Date();
        }

        function Send() {
            if ($("#btnSendMsg").attr("flag") == "hong") {
                $.ajax({
                    type: "get",
                    url: "../ashx/sendmsg.ashx",
                    data: "mobile=" + $("#txtMobile").val() + "&verifycode=" + $("#txtVerifyCode").val() + "&d=" + new Date().toString(),
                    success: function (data) {
                        if (data == "1") {
                            $("#btnSendMsg").css("background-color", "#b9b9b9");
                            $("#btnSendMsg").attr("flag", "hui");
                            $("#num").text("60");
                            timer = setInterval("CountDown()", 1000);
                        }
                        else if (data == "-1") {
                            alert("手机格式错误");
                        }
                        else if (data == "-2") {
                            alert("短信发送失败，请重试");
                        }
                        else if (data == "-4") {
                            alert("验证码错误");
                        }
                    },
                    error: function (data) {
                        alert(data);
                    }
                })

            }
        }

        var timer = null;

        function CountDown() {
            var now = $("#num").text();
            if (now > 0) {
                now = now - 1;
                $("#num").text(now);
            }
            else {
                clearInterval(timer);
                $("#num").text("");
                $("#btnSendMsg").css("background-color", "#e4393c");
                $("#btnSendMsg").attr("flag", "hong");
            }
        }

        function Modify() {
            if ($("txtMobile").val() == "") {
                alert("请输入手机号");
                return false;
            }
            if ($("#txtCode").val() == "") {
                alert("请输入验证码");
                return false;
            }
            if ($("#txtPwd").val() == "") {
                alert("请输入密码");
                return false;
            }
            if ($("#txtPwd").val().length < 6) {
                alert("请至少输入六个字符密码");
                return false;
            }
            if ($("#txtPwd").val() != $("#txtPwd2").val()) {
                alert("两次输入密码不一致");
                return false;
            }
            $.ajax({
                type: "get",
                url: "findpwd.aspx",
                data: "sync=true&ope=reg&username=" + $("#txtMobile").val() + "&pwd=" + $("#txtPwd").val() + "&code=" + $("#txtCode").val() + "&d=" + new Date().toString(),
                success: function (data) {
                    if (data == "1") {
                        window.location.href = "default.aspx";
                    }
                    else if (data == "-1") {
                        alert("验证码错误");
                    }
                    else if (data == "-2") {
                        alert("验证码超时");
                    }
                    else if (data == "-3") {
                        alert("用户不存在");
                    }
                    else {
                        alert("注册失败");
                    }
                },
                error: function (data) {
                    alert(data);
                }
            })
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <header class="mui-bar">
			<a class="mui-action-back gotoup mui-pull-left"></a>
			<h1 class="mui-title">修改密码</h1>
		</header>
    <div class="mui-content pad-btm-60">
        <div class="mui-input-group" style="margin: 10px 0 20px 0;">
            <div class="mui-input-row">
                <input type="text" id="txtMobile" class="mui-input-clear" placeholder="请输入手机号">
            </div>
            <div class="mui-input-row">
                <input type="text" id="txtVerifyCode" class="mui-input-clear" style="width: 61%;" placeholder="请输入验证码">
                <img
                        id="authImg" align="absmiddle" onclick="refresh()" style="cursor: pointer;"
                        alt="看不清？点击更换" src="../ValidateCode2.aspx" />
            </div>
            <div class="mui-input-row">
                <input type="text" id="txtCode" class="mui-input-clear" style="width: 61%;" placeholder="请输入验证码">
                <button id="btnSendMsg" style="background-color:#e4393c;" class="getcode" flag="hong" onclick="Send();" type="button">
                    获取验证码<span id="num"></span></button>
            </div>
            <div class="mui-input-row">
                <input type="text" id="txtPwd" class="mui-input-clear" placeholder="请输入密码">
            </div>
            <div class="mui-input-row">
                <input type="text" id="txtPwd2" class="mui-input-clear" placeholder="请输入确认密码">
            </div>
        </div>
        <div class="pad-10">
            <button class="login-btn" id="btnRegister" type="button" onclick="Modify();">
                确定</button>
        </div>
    </div>
    </form>
</body>
</html>
